package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TFee;
import com.ruoyi.system.service.ITFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 宿舍缴费管理Controller
 * 
 * @author cyh
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/fee")
public class TFeeController extends BaseController
{
    @Autowired
    private ITFeeService tFeeService;

    /**
     * 查询宿舍缴费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:fee:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFee tFee)
    {
        startPage();
        List<TFee> list = tFeeService.selectTFeeList(tFee);
        return getDataTable(list);
    }

    /**
     * 导出宿舍缴费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:fee:export')")
    @Log(title = "宿舍缴费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TFee tFee)
    {
        List<TFee> list = tFeeService.selectTFeeList(tFee);
        ExcelUtil<TFee> util = new ExcelUtil<TFee>(TFee.class);
        util.exportExcel(response, list, "宿舍缴费管理数据");
    }

    /**
     * 获取宿舍缴费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fee:query')")
    @GetMapping(value = "/{feeId}")
    public AjaxResult getInfo(@PathVariable("feeId") Long feeId)
    {
        return success(tFeeService.selectTFeeByFeeId(feeId));
    }

    /**
     * 新增宿舍缴费管理
     */
    @PreAuthorize("@ss.hasPermi('system:fee:add')")
    @Log(title = "宿舍缴费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFee tFee)
    {
        return toAjax(tFeeService.insertTFee(tFee));
    }

    /**
     * 修改宿舍缴费管理
     */
    @PreAuthorize("@ss.hasPermi('system:fee:edit')")
    @Log(title = "宿舍缴费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFee tFee)
    {
        return toAjax(tFeeService.updateTFee(tFee));
    }

    /**
     * 删除宿舍缴费管理
     */
    @PreAuthorize("@ss.hasPermi('system:fee:remove')")
    @Log(title = "宿舍缴费管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feeIds}")
    public AjaxResult remove(@PathVariable Long[] feeIds)
    {
        return toAjax(tFeeService.deleteTFeeByFeeIds(feeIds));
    }
}
